/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package lolbuilder.Champions.Interf;

import java.util.ArrayList;


/**
 *
 * @author chocoboSan
 */
public class Spell {
    public boolean hasAdRatio=false;
    public boolean hasApRatio=false;
    
    public boolean isSumAdAp=false;
    public boolean isPhyDmg=false;
    public boolean isMgcDmg=false;
    public boolean isTrueDmg=false;
    public double baseDmg=0;
    public double apRatio=0;
    public double adRatio=0;
    
    
    public boolean hasEffect=false;
    public Effect effect;
    
    public double cd=0;
    public double currentCD=0;
    public boolean isOnCd=false;
    public double curCDR=0;

    public Spell() {
        
    }

    public void setBaseDamage(int baseDamages[],int lvl) {
        if (lvl==0) baseDmg=0;
        baseDmg=baseDamages[lvl-1];
    }
    
    public double getDmgDealtOnThisChamp(DummyChamp me, DummyChamp target) {
        if (isOnCd) return 0;
        if (hasEffect) {
            
            effect.applyEffect(me,target);
            
        }
        float dmgFromSpells=0;
        float adDmgSpell=(float) ((baseDmg+me.ad*adRatio));
        if (isPhyDmg) adDmgSpell=adDmgSpell-adDmgSpell*me.getPercentReducForArmorPen(target.arm);
        dmgFromSpells+=adDmgSpell;
        
        float apDmgSpell=(float) ((baseDmg+me.ap*apRatio));
        if (isMgcDmg) apDmgSpell=apDmgSpell-apDmgSpell*me.getPercentReducForMagicPen(target.rm);
        dmgFromSpells+=apDmgSpell;
        
        if (isTrueDmg) dmgFromSpells+=(baseDmg);
        isOnCd=true;
        return dmgFromSpells;
    }
    
    public void updateTick(float nb_sec) {
        if (isOnCd) {
            currentCD+=nb_sec;
            if (currentCD>=cd) {
                isOnCd=false;
                currentCD=0;
            } else if (hasEffect) {
                if (currentCD>=effect.effectDuration && effect.activated) {
                    effect.removeEffect();
                    
                }
            }
        }
    }
    
    public void addCdr(float cdr) {
        if (curCDR+cdr>40) {
            float realCDR=(float) (40-curCDR);
            cd=cd-cd*realCDR/100;
            curCDR=40;
        } else {
            curCDR+=cdr;
            cd=cd-cd*cdr/100;
        }
    }
    
    public double getAdRatio() {
        return adRatio;
    }

    public void setAdRatio(double adRatio) {
        this.adRatio = adRatio;
    }

    public double getApRatio() {
        return apRatio;
    }

    public void setApRatio(double apRatio) {
        this.apRatio = apRatio;
    }

    public double getBaseDmg() {
        return baseDmg;
    }

    public void setBaseDmg(double baseDmg) {
        this.baseDmg = baseDmg;
    }

    public double getCd() {
        return cd;
    }

    public void setCd(double cd) {
        this.cd = cd;
    }

    public double getCurCDR() {
        return curCDR;
    }

    public void setCurCDR(double curCDR) {
        this.curCDR = curCDR;
    }

    public double getCurrentCD() {
        return currentCD;
    }

    public void setCurrentCD(double currentCD) {
        this.currentCD = currentCD;
    }

    public boolean isHasAdRatio() {
        return hasAdRatio;
    }

    public void setHasAdRatio(boolean hasAdRatio) {
        this.hasAdRatio = hasAdRatio;
    }

    public boolean isHasApRatio() {
        return hasApRatio;
    }

    public void setHasApRatio(boolean hasApRatio) {
        this.hasApRatio = hasApRatio;
    }

    public boolean isHasEffect() {
        return hasEffect;
    }

    public void setHasEffect(boolean hasEffect) {
        this.hasEffect = hasEffect;
    }

    public boolean isIsMgcDmg() {
        return isMgcDmg;
    }

    public void setIsMgcDmg(boolean isMgcDmg) {
        this.isMgcDmg = isMgcDmg;
    }

    public boolean isIsOnCd() {
        return isOnCd;
    }

    public void setIsOnCd(boolean isOnCd) {
        this.isOnCd = isOnCd;
    }

    public boolean isIsPhyDmg() {
        return isPhyDmg;
    }

    public void setIsPhyDmg(boolean isPhyDmg) {
        this.isPhyDmg = isPhyDmg;
    }

    public boolean isIsSumAdAp() {
        return isSumAdAp;
    }

    public void setIsSumAdAp(boolean isSumAdAp) {
        this.isSumAdAp = isSumAdAp;
    }

    public boolean isIsTrueDmg() {
        return isTrueDmg;
    }

    public void setIsTrueDmg(boolean isTrueDmg) {
        this.isTrueDmg = isTrueDmg;
    }

    
    
    
}
